package com.hao.state;
// 测试礼让线程
// 礼让不一定成功，看CPU心情
public class testYield {
    public static void main(String[] args) throws InterruptedException {
        MyYield myYield = new MyYield();
        new Thread(myYield,"a").start();
        new Thread(myYield,"b").start();
        new Thread(myYield,"c").start();
    }
}
class MyYield implements Runnable{
    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        System.out.println(name+"线程开始执行");
        Thread.yield();
        System.out.println(name+"线程停止执行");
    }
}

